home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / DEVPARAM.C < prev    next >
C/C++ Source or Header  |  1996-12-23  |  2KB  |  81 lines

  1. #include "global.h"
  2. #include "ctype.h"
  3. #include "devparam.h"
  4.  
  5. #if !defined(_lint)
  6. static char rcsid[] OPTIONAL = "$Id: devparam.c,v 1.12 1996/12/23 20:37:36 root Exp root $";
  7. #endif
  8.  
  9. struct param {
  10.     int number;
  11.     const char *name;
  12. };
  13. static struct param Parms[] = {
  14.     { PARAM_DATA,        "Data" },
  15.     { PARAM_TXDELAY,    "TxDelay" },
  16.     { PARAM_PERSIST,    "Persist" },
  17.     { PARAM_SLOTTIME,    "SlotTime" },
  18.     { PARAM_TXTAIL,        "TxTail" },
  19.     { PARAM_FULLDUP,    "FullDup" },
  20.     { PARAM_HW,        "Hardware" },
  21.     { PARAM_MUTE,        "TxMute" },
  22.     { PARAM_DTR,        "DTR" },
  23.     { PARAM_RTS,        "RTS" },
  24.     { PARAM_SPEED,        "Speed" },
  25.     { PARAM_ENDDELAY,    "EndDelay" },
  26.     { PARAM_GROUP,        "Group" },
  27.     { PARAM_IDLE,        "Idle" },
  28.     { PARAM_MIN,        "Min" },
  29.     { PARAM_MAXKEY,        "MaxKey" },
  30.     { PARAM_WAIT,        "Wait" },
  31.     { PARAM_DOWN,        "Down" },
  32.     { PARAM_UP,        "Up" },
  33.     { PARAM_BLIND,        "Blind" },
  34.     { PARAM_RCV_MODE,    "RcvMode"}, /* packet driver receive mode - WG7J */
  35.     { PARAM_RETURN,        "Return" },
  36.     { PARAM_RETURN2,    "Return2" },
  37.     { -1,            NULLCHAR }
  38. };
  39.     
  40. /* Convert a packet radio interface control token into a number
  41.  * Used by the various ioctl routines and by KISS TNC commands
  42.  */
  43. int
  44. devparam(s)
  45. char *s;
  46. {
  47.     int len;
  48.     struct param *sp;
  49.  
  50.     if (s)    {
  51.         len = (int) strlen(s);
  52.         if(isdigit(s[0]))
  53.             return atoi(s);
  54.  
  55.         sp = &Parms[0];
  56.         while(sp->number != -1){
  57.             if(strnicmp(s,sp->name,(size_t)len) == 0)
  58.                 return sp->number;
  59.             sp++;
  60.         }
  61.     }        
  62.     return -1;
  63. }
  64.  
  65. const char *
  66. parmname(n)
  67. int n;
  68. {
  69.     struct param *sp;
  70.  
  71.     sp = &Parms[0];
  72.     while(sp->number != -1){
  73.         if(sp->number == n)
  74.             return sp->name;
  75.         sp++;
  76.     }        
  77.     return NULLCHAR;
  78. }
  79.  
  80.  
  81.